<?php
/**
 * 全局配置
 */
$config = [
    'id' => 'app',
    'language' => 'zh-CN',
    'basePath' => __DIR__,
    'bootstrap' => ['debug'],
    'controllerNamespace' => 'app\controllers',
    'aliases' => [
        '@bower' => '@vendor/yidas/yii2-bower-asset/bower',
        '@app' => __DIR__,
        '@components' => '@app/components',
    ],
    'components' => [

        'permission' => [
            'class' => app\components\casbin\CasbinHeader::class,
            'model' => [
                // Available Settings: "file", "text"
                'config_type' => 'file',
                'config_file_path' => __DIR__ . '/components/casbin/casbin-model.conf',
                'config_text' => '',
            ],
            'adapter' => app\components\casbin\adapter::class,
        ],

        'cache' => ['class' => 'yii\caching\FileCache'],
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=crm_basic',
            'username' => 'root',
            'password' => '123456',
            'charset' => 'utf8',
            'tablePrefix' => 'pre_',
            'enableSchemaCache' => true,
            'schemaCacheDuration' => 3600,
            'schemaCache' => 'cache',
        ],
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
        'response' => [
            'class' => 'yii\web\Response',
            'format' => \yii\web\Response::FORMAT_JSON,
            'on beforeSend' => ['app\components\events\ResponseEvent', 'beforeSend'],
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
            'enableSession' => false,
        ],
        'request' => [
            'cookieValidationKey' => 'O1d232t3ak1xww-M97_7QvwPo-5QGdkLMp98OU',
            'parsers' => ['application/json' => 'yii\web\JsonParser'],
            'enableCookieValidation' => false
        ],
        'errorHandler' => ['errorAction' => 'error/index'],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'debug/<c>/<a>' => 'debug/<c>/<a>',
            ],
        ],
        'i18n' => [
            'translations' => [
                '*' => [
                    'class' => \yii\i18n\PhpMessageSource::class,
                    'fileMap' => [
                        'basic' => 'basic.php'
                    ]
                ]
            ]
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
    ],
    'params' => include __DIR__ . '/params.php',
];
//if (YII_ENV_DEV) {
//    // configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
    'class' => 'yii\debug\Module',
    // uncomment the following to add your IP if you are not connecting from localhost.
    //'allowedIPs' => ['127.0.0.1', '::1'],
];
//
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
    'class' => 'yii\gii\Module',
    // uncomment the following to add your IP if you are not connecting from localhost.
    //'allowedIPs' => ['127.0.0.1', '::1'],
    'generators' => [
        'model' => [ //生成器名称
            'class' => 'yii\gii\generators\model\Generator',
            'templates' => [ //设置我们自己的模板
                //模板名 => 模板路径
                'AFUC_Model' => '@components/gii/templates/model/AFUC',
            ]
        ]
    ],
];
//}

return $config;